/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dbhandler;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Harjeet
 */
public class newuserreg {
    
    public 
    boolean newuserregquery(entityclasses.user newuser )         
    {
        String Query,Query1;
        
        java.util.Date dt = new java.util.Date();
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String currentTime = sdf.format(dt);
       // System.out.print(currentTime);
        
        Query = "insert into tbl_users(`user_id`,`fname`,`mname`,`lname`,`prog_id`,`CPI`,`hostel_resi`,`hostel_wing`,`hostel_floor_no`,`contact_no`,`image_path`,`backlogs`,`last_update`) values("+ newuser.getEmailid() +",'"+ newuser.getFirstname() +"',' "+ newuser.getMiddlename() +" ',' " +newuser.getLastname()+ " ',12,'"+newuser.getCpi()+"',"+newuser.isInhostel()+",'"+newuser.getWing()+"','"+newuser.getFloor()+"','"+newuser.getContactno()+"','demo','"+newuser.getBacklogs()+"','"+ currentTime +"');";
        Query1="Insert into tbl_user_credentials(`user_id`,`password`,`role_id`,`is_candidate`,`has_voted`) values("+newuser.getEmailid()+",'"+newuser.getPassword()+"',1,0,0);";
        System.out.print(Query+"\n");
        dbhandler.DBConnection db = new dbhandler.DBConnection();
        db.connect();
        try {
            if(db.executeQuery(Query))
            { 
            db.executeQuery(Query1);}
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        db.disconnect();
        
        
        return true;
    }
    public static void main(String args[])
    {
        newuserreg newusr = new  newuserreg();
        try {
           // newusr.newuserregquery();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    
}

/*entityclasses.user newuser
 * insert into tbl_users('user_id','fname','mname','lname','prog_id','CPI','hostel_resi',
'hostel_wing','hostel_room_no','contact_no','image_path','backlogs',
'last_update') values(201112063,'Sohil','K','Parekh',12,
'5.9','1','D','3','9428056413','demo','0','17-10-2012 11:32:00 AM');

 */
